import { Component, OnInit, Input, Output, EventEmitter, Inject } from '@angular/core';
import { ActivatedRoute, Params,Router } from '@angular/router';
import { ConmonService } from "../../service/common.service";
@Component({
  selector: 'app-head-title',
  templateUrl: './head-title.component.html',
  styleUrls: ['./head-title.component.scss']
})
export class HeadTitleComponent implements OnInit {
  private _title: string = "";
  private _isscreen: boolean = false;
  private headTitle: boolean = false;
  @Input()
  set title(title: string) {
    this._title = title;
  }
  get title(): string {
    return this._title;
  }
  @Input()
  set isscreen(isscreen: boolean) {
    this._isscreen = isscreen;
  }
  get isscreen(): boolean {
    return this._isscreen;
  }
  @Output()
  public follow = new EventEmitter<string>();
  // get panelTitle():string{
  //   return this.title;
  // }

  public emitAnEvent(event): void {
    this.follow.emit("follow");
  }
  // get emitIsScreen():string{
  //   return this._IsScreen;
  // }
  emitBack() {
    let url = this.routerIonfo.snapshot.url[0].path;
    if (url === 'workAdd' || url === 'PersonTatal' || url === 'WorkAudit' || url === 'ProjectTotal') {
      this.router.navigate(['/home']);
      this.service.personScreeningData = undefined;
      this.service.projectScreeningData = undefined;
      this.service.personScreeningPostData = undefined;
      this.service.projectScreeningPostData = undefined;
    } else if (url != 'home') {
      window.history.go(-1);
    }
  }
  goBack(): void {
    console.log(this)
    // this.location.back();
  }
  public childFn(): void {
    // console.log("子组件的名字是>"+this.panelTitle);
  }
  constructor( @Inject(ActivatedRoute) private routerIonfo: ActivatedRoute,private router:Router,private service: ConmonService) {
    if (this.routerIonfo.snapshot.url[0].path === 'home') {
      this.headTitle = false;
    } else {
      this.headTitle = true; 
    }
  }
  ngOnInit() {

    console.log(this.routerIonfo.snapshot.url[0].path);
    
  }

}
